package com.yuexun.beilunpatient.ui.login.model.impl;


import com.yuexun.beilunpatient.ui.bean.BaseListEntity;
import com.yuexun.beilunpatient.ui.login.api.LoginApi;
import com.yuexun.beilunpatient.ui.login.bean.RegisterBean;
import com.yuexun.beilunpatient.ui.login.bean.SmsBean;
import com.yuexun.beilunpatient.ui.login.bean.LoginBean;
import com.yuexun.beilunpatient.ui.login.bean.UserDtlBean;
import com.yuexun.beilunpatient.ui.login.model.ILoginModel;
import com.yuexun.beilunpatient.utils.ApiUtil;

import java.util.Map;

import rx.Observable;

/**
 * Created by chenss on 2018/3/14 0014.
 */

public class LoginModel implements ILoginModel {

    private LoginApi api;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginModel.class);

    public LoginApi ApiInstance() {
        if (api != null) {
            return api;
        } else {
            return ApiUtil.getInstance().createRetrofitApi(LoginApi.class);
        }
    }

    @Override
    public Observable<BaseListEntity<LoginBean>> loginInPatient(Map<String, String> praise) {
        api = ApiInstance();
        return api.loginInPatient(praise);
    }

    @Override
    public Observable<BaseListEntity<SmsBean>> registerOfPatientSms(Map<String, String> praise) {
        api = ApiInstance();
        return api.registerOfPatientSms(praise);
    }

    @Override
    public Observable<BaseListEntity<RegisterBean>> registerOfPatient(Map<String, String> praise) {
        api = ApiInstance();
        return api.registerOfPatient(praise);
    }

    @Override
    public Observable<BaseListEntity<UserDtlBean>> loadPatientInfoDetail(Map<String, String> praise) {
        api = ApiInstance();
        return api.loadPatientInfoDetail(praise);
    }

    @Override
    public Observable<BaseListEntity<SmsBean>> resetPasswordOfSms(Map<String, String> praise) {
        api = ApiInstance();
        return api.resetPasswordOfSms(praise);
    }

    @Override
    public Observable<BaseListEntity<LoginBean>> resetPassword(Map<String, String> praise) {
        api = ApiInstance();
        return api.resetPassword(praise);
    }
}
